<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>博客管理系统</title>
  <link rel="stylesheet" href="../../../static/back/css/login.css">
  <script type="text/javascript" src="../../../static/back/js/jquery.min.js"></script>
  <script type="text/javascript" src="../../../static/back/js/index.js"></script>
  <script src="../../../static/back/lib/layui/layui.js" charset="utf-8"></script>
</head>
<body class="login-bg">
    <canvas id="fullstarbg">你的浏览器不支持canvas标签</canvas>
    <div class="login">
        <div class="message">博客系统登录</div>
        <div id="darkbannerwrap"></div>
        <div style="color: red;font-size: 24px">{{ errorMsg }}</div>
        <form method="post" class="layui-form" onsubmit="return false;" id="myform">
            {% csrf_token %}
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>
    <script>
            layui.use(['form','jquery','layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //监听提交
                form.on('submit(login)',
					function(data) {
                        //发起ajax请求 $.post(url,param,回调函数,设置响应的数据类型)
                        var url='/back/login';
                        var param=$('#myform').serialize()
                        $.post(url,param,function (res) {
                            //res:服务器端响应的数据
                            if(res.success){
                                window.location.href = "/back/index";
                            }else{
                                layer.msg(res.message,{icon:6})
                            }
                        },'json')

						//window.location.href = "/back/index";
						//return false;
					}
				);
            });

        </script>

    
    <!-- 底部结束 -->
    
</body>
</html>